package cn.ajb.filemanager.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.ajb.filemanager.entity.SysParamDict;
import cn.ajb.filemanager.entity.User;
import cn.ajb.filemanager.service.SysParamDictService;
import cn.ajb.filemanager.service.UserService;
import cn.ajb.filemanager.util.Contant;
import cn.ajb.filemanager.util.JSONResult;

/**
 * 用户控制类
 * @author zoujing
 *
 */
@Controller
@RequestMapping(value="/sysParamDictController")
public class SysParamDictController {
	@Autowired
	private SysParamDictService sysParamDictService;
	@Autowired
	private UserService userService;
	
	@RequestMapping(value="/selectSysParamDictlist")
	public String selectSysParamDictlist(ModelMap modelMap){
		List<Object> list = new ArrayList<Object>();
		List<SysParamDict> spdList = sysParamDictService.selectSysParamDictlist();
		modelMap.put("spdList", spdList);
		return "fileUpload";
	}
	@RequestMapping(value="/selectSysParamDictByType")
	public @ResponseBody List<SysParamDict> selectSysParamDictByType(@RequestParam(required = true) Integer type){
		return sysParamDictService.selectSysParamDictByType(type);
	}
	
	@RequestMapping(value="/getSysParamDictByType")
	public String selectSysParamDictByType(@RequestParam(required = true)String type,ModelMap modelMap){
		if(Contant.UPLOAD_USER.equals(type)){
			List<SysParamDict> userList = sysParamDictService.selectSysParamDictByType(10);
			modelMap.put("userList", userList);
		}else if(Contant.SYS_TYPE.equals(type)){
			List<SysParamDict> sysList = sysParamDictService.selectSysParamDictByType(1);
			modelMap.put("sysList", sysList);
		}else if(Contant.PRODUCT_TYPE.equals(type)){
			List<SysParamDict> sysList = sysParamDictService.selectSysParamDictByType(3);
			modelMap.put("sysList", sysList);
		}else if(Contant.PRODUCT_MODEL.equals(type)){
			List<SysParamDict> sysList = sysParamDictService.selectSysParamDictByType(4);
			modelMap.put("sysList", sysList);
		}else if(Contant.PRODUCT_NAME.equals(type)){//
			List<SysParamDict> sysList = sysParamDictService.selectSysParamDictByType(2);
			modelMap.put("sysList", sysList);
		}else if(Contant.VERSION.equals(type)){
			List<SysParamDict> sysList = sysParamDictService.selectSysParamDictByType(7);
			modelMap.put("sysList", sysList);
		}else if(Contant.USAGE_SCENARIOS.equals(type)){
			List<SysParamDict> sysList = sysParamDictService.selectSysParamDictByType(5);
			modelMap.put("sysList", sysList);
		}else if(Contant.SPECIAL_NUM.equals(type)){
			List<SysParamDict> sysList = sysParamDictService.selectSysParamDictByType(9);
			modelMap.put("sysList", sysList);
		}else if(Contant.DOCUMENT_TYPE.equals(type)){
			List<SysParamDict> sysList = sysParamDictService.selectSysParamDictByType(6);
			modelMap.put("sysList", sysList);
		}else if(Contant.MATERIEL.equals(type)){
			List<SysParamDict> sysList = sysParamDictService.selectSysParamDictByType(8);
			modelMap.put("sysList", sysList);
		}
		return "updateSysParam";
	}
	
	@RequestMapping(value="/updateSysParam")
	public @ResponseBody JSONResult<String> updateSysParam(@RequestParam(required = true)String type,String[] name){
		return sysParamDictService.updateSysParam(type, name);
	}
	@RequestMapping(value="/searchSysParamlist")
	public String searchSysParamlist(ModelMap modelMap){
		List<Object> list = new ArrayList<Object>();
		List<SysParamDict> spdList = sysParamDictService.selectSysParamDictlist();
		modelMap.put("spdList", spdList);
		return "searchFile";
	}
}






